package com.amita.ez.base;


import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class ExceptionAdvisor {

    @ResponseBody
    @ExceptionHandler(value = Exception.class)
//    @ResponseStatus
    public Object exceptionHandler(Exception e) {
//        return new Result(HttpStatus.BAD_REQUEST.value(), e.getMessage());
       e.printStackTrace();
        return R.failed(e.getMessage());
    }

    @ResponseBody
    @ExceptionHandler(value = RuntimeException.class)
//    @ResponseStatus(code = HttpStatus.BAD_REQUEST)
    public Object formatCheckExceptionHandler(RuntimeException e) {
//        return new Result(HttpStatus.BAD_REQUEST.value(), e.getMessage());
        e.printStackTrace();
        return R.failed(e.getMessage());
    }

}
